﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LocalServerApp
{
    public class Person
    {
        public string Name { get; set; }
        public string HashIdentifier { get; set; }
        public string Adress { get; set; }
        public string Zipcode { get; set; }
        public bool? Male { get; set; }
        public string Birthday { get; set; }

        private List<Hanger> hangers = new List<Hanger>();

        public void addHanger(Hanger h)
        {
            if (!hangers.Contains(h))
            {
                hangers.Add(h);
            }
        }

        public void removeHanger(Hanger h)
        {
            if (hangers.Contains(h))
            {
                hangers.Remove(h);
            }
        }

        public List<Hanger> Hanger
        {
            get { return hangers; }
        }

        public override bool Equals(object obj)
        {
            Person p = obj as Person;

            if (p != null)
            {
                if (p.HashIdentifier.Equals(this.HashIdentifier))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }

    }

    public class Hanger
    {
        private int hangerNo;
        private Person person;

        public Person Person
        {
            get { return person; }
            set { person = value; }
        }

        public int HangerNo
        {
            get { return hangerNo; }
            set { hangerNo = value; }
        }

        public override bool Equals(object obj)
        {
            Hanger h = obj as Hanger;

            if (h != null)
            {
                if (h.HangerNo.Equals(this.HangerNo))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
    }
}
